﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Web.Mvc;
using System.Web.Security;
using System.Data.Entity.ModelConfiguration;

namespace Project_1.Models
{
    public class User
    {
        public string Username { get; set; }
        public string Password { get; set; }
        public int Type { get; set; }
        public DateTime CreateTime { get; set; }
        public DateTime LastVisit { get; set; }
        public int Point { get; set; }
        public bool Avatar { get; set; }
        public string RealName { get; set; }
        public string Email { get; set; }
        public DateTime Birthday { get; set; }
        public bool Gender { get; set; }
        public string Phone { get; set; }
        public string HomePage { get; set; }
        public string Location { get; set; }
        public string SubcribeUsers { get; set; }
        public string AboutMe { get; set; }
        public int CommentViewStyle { get; set; }
        public int ListViewStyle { get; set; }
        public bool AllowInfoView { get; set; }
    }

    public class UserConfiguration : EntityTypeConfiguration<User>
    {
        public UserConfiguration() : base()
        {
            HasKey(p => p.Username);
            Property(p => p.Username).
                HasColumnName("Username").
                IsRequired();
            Property(p => p.Password).
                HasColumnName("Password").
                IsRequired();
            Property(p => p.Type).
                HasColumnName("Type").
                IsRequired();
            Property(p => p.CreateTime).
                HasColumnName("CreateTime").
                IsRequired();
            Property(p => p.LastVisit).
                HasColumnName("LastVisit").
                IsRequired();
            Property(p => p.Point).
                HasColumnName("Point");
            Property(p => p.Avatar).
                HasColumnName("Avatar").
                IsRequired();
            Property(p => p.RealName).
                HasColumnName("RealName");
            Property(p => p.Email).
                HasColumnName("Email");
            Property(p => p.Birthday).
                HasColumnName("Birthday");
            Property(p => p.Gender).
                HasColumnName("Gender");
            Property(p => p.Phone).
                HasColumnName("Phone");
            Property(p => p.HomePage).
                HasColumnName("HomePage");
            Property(p => p.Location).
                HasColumnName("Location");
            Property(p => p.SubcribeUsers).
                HasColumnName("SubcribeUsers");
            Property(p => p.AboutMe).
                HasColumnName("AboutMe");
            Property(p => p.CommentViewStyle).
                HasColumnName("CommentViewStyle").
                IsRequired();
            Property(p => p.ListViewStyle).
                HasColumnName("ListViewStyle").
                IsRequired();
            Property(p => p.AllowInfoView).
                HasColumnName("AllowInfoView").
                IsRequired();
            ToTable("Users");
        }
    }

    public class ChangePasswordModel
    {
        [Required]
        [DataType(DataType.Password)]
        [Display(Name = "Current password")]
        public string OldPassword { get; set; }

        [Required]
        [StringLength(32, ErrorMessage = "The password must be between 6 and 32 characters long", MinimumLength = 6)]
        [DataType(DataType.Password)]
        [Display(Name = "New password")]
        public string NewPassword { get; set; }

        [DataType(DataType.Password)]
        [Display(Name = "Confirm new password")]
        [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
        public string ConfirmPassword { get; set; }
    }

    public class LogOnModel
    {
        [Required]
        [Display(Name = "User name")]
        public string UserName { get; set; }

        [Required]
        [DataType(DataType.Password)]
        [Display(Name = "Password")]
        public string Password { get; set; }

        [Display(Name = "Remember me?")]
        public bool RememberMe { get; set; }
    }

    public class RegisterModel
    {
        [Required]
        [Display(Name = "Username")]
        public string UserName { get; set; }

        [Required]
        [DataType(DataType.EmailAddress)]
        [Display(Name = "Email")]
        public string Email { get; set; }

        [Required]
        [StringLength(32, ErrorMessage = "The password must be between 6 and 32 characters long", MinimumLength = 6)]
        [DataType(DataType.Password)]
        [Display(Name = "Password")]
        public string Password { get; set; }

        [DataType(DataType.Password)]
        [Display(Name = "Confirm password")]
        [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
        public string ConfirmPassword { get; set; }
    }

    public class ChangeInformationModel
    {
        [Display(Name = "Avatar")]
        public bool Avatar { get; set; }

        [Display(Name = "Real name")]
        public string RealName { get; set; }

        [Display(Name = "Email")]
        public string Email { get; set; }

        [Display(Name = "Birthday")]
        public DateTime Birthday { get; set; }

        [Display(Name = "Gender")]
        public bool Gender { get; set; }

        [Display(Name = "Phone")]
        public string Phone { get; set; }

        [Display(Name = "Home page")]
        public string HomePage { get; set; }

        [Display(Name = "Location")]
        public string Location { get; set; }

        [Display(Name = "Subcribed users")]
        public string SubcribeUsers { get; set; }

        [Display(Name = "About me")]
        public string AboutMe { get; set; }

        [Display(Name = "Comment view style")]
        public int CommentViewStyle { get; set; }

        [Display(Name = "List view style")]
        public int ListViewStyle { get; set; }

        [Display(Name = "Allow information view")]
        public bool AllowInfoView { get; set; }
    }
}
